<!-- #layout name=blank -->
<div class="page-header">
    <h1 class="title">Styles</h1>
</div>
<div data-bind="component: { name: 'kb-breadcrumb', params:[{
    name: 'SITES'
},{
    name: 'DASHBOARD'
},{
    name: Kooboo.text.common.Styles
}]}"></div>
<div class="navbar navbar-default">
    <div class="container-fluid">
        <div class="btn-group navbar-btn">
            <button data-toggle="dropdown" class="btn green"><span>Create</span> <i class="fa fa-angle-down"></i></button>
            <ul role="menu" class="dropdown-menu">
                <li><a data-bind="attr: { href: styleCreateUrl }">Style</a></li>
                <li><a data-bind="click: createGroup" href="javascript:;">Group</a></li>
            </ul>
        </div>
        <a class="btn green btn-file navbar-btn upload-link">
            <span>Upload styles</span>
            <input type="file" multiple data-bind="upload: {
                allowMultiple: true,
                acceptTypes: ['application/x-pointplus','text/css'],
                acceptSuffix: ['css'],
                callback: uploadStyle
            }">
        </a>
        <a data-bind="visible: showDeleteBtn, click: onDelete" class="btn red navbar-btn">Delete</a>
    </div>
</div>
<ul class="nav nav-tabs" data-bind="foreach:types">
    <li data-bind="css: { 'active' : $data.value === $parent.curType() }">
        <a href="javascript:;" data-bind="text: $data.displayName, click: $parent.fetchDataByType.bind(this, $data.value)"></a>
    </li>
</ul>
<div data-bind="component: { name: 'kb-table', params: tableData }"></div>
<div data-bind="modal: groupModal" class="modal fade" data-backdrop="static" data-keyboard="false">
    <form data-bind="submit: onGroupModalSubmit">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button data-bind="click: hideGroupModal" class="close"><i class="fa fa-close"></i></button>
                    <h4 data-bind="text: groupName() || Kooboo.text.site.script.groupName " class="modal-title"></h4>
                </div>
                <div class="modal-body">
                    <!-- ko if: isGroupNew -->
                    <div class="form-horizontal">
                        <div class="form-group margin-bottom-20">
                            <label class="control-label col-md-2">Name</label>
                            <div class="col-md-10">
                                <input type="text" class="form-control" data-bind="textInput: groupName, error: groupName, event: { keydown: handleEnter }" />
                            </div>
                        </div>
                    </div>
                    <!-- /ko -->
                    <div class="navbar navbar-default">
                        <div class="container-fluid">
                            <div class="navbar-form navbar-left">
                                <div class="form-group">
                                    <select data-bind="options: availableOptions, optionsValue: 'routeId', optionsText: 'name', value: selectedOption" class="form-control">
                                    </select>
                                    <button data-bind="enable: availableOptions().length, click: addGroupItem" class="btn blue">Add</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <table class="table table-striped table-hover">
                        <thead>
                            <tr>
                                <th class="table-sortable"></th>
                                <th>Style</th>
                                <th class="table-action"></th>
                            </tr>
                        </thead>
                        <!-- ko if: groupChildren().length -->
                        <tbody data-bind="sortable: groupChildren" class="ui-sortable">
                            <tr>
                                <td class="table-sortable"><span class="sortable ui-sortable-handle"><i class="glyphicon glyphicon-list"></i></span></td>
                                <td data-bind="text: $data.name"></td>
                                <td>
                                    <button data-bind="click: $root.removeItem" class="btn btn-xs red">Remove</button>
                                </td>
                            </tr>
                        </tbody>
                        <!-- /ko -->
                        <!-- ko ifnot: groupChildren().length > 0 -->
                        <tbody>
                            <tr>
                                <td colspan="100" class="text-center">Empty</td>
                            </tr>
                        </tbody>
                        <!-- /ko -->
                    </table>
                </div>
                <div class="modal-footer">
                    <button class="btn green" type="submit" data-bind="text: Kooboo.text.common[isGroupNew() ? 'create' : 'save']"></button>
                    <button class="btn gray" data-bind="click: hideGroupModal">Cancel</button>
                </div>
            </div>
        </div>
    </form>
</div>
<div data-bind="modal: inlineModal" class="modal fade" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button data-bind="click: hideInlineModal" class="close"><i class="fa fa-close"></i></button>
                <h4 class="modal-title">Inline</h4>
            </div>
            <div class="modal-body">
                <div class="block-style-editor" style="overflow: inherit;">
                    <div id="inline_ed">
                        <div class="block-style-editor-v2" data-bind="component: { name: 'kb-style-list', params: { rules: styleRules(), showRelationBtn: false, getRules: getStyleRules }}"></div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button data-bind="click: saveInlineModal" class="btn green">Save</button>
                <button data-bind="click: hideInlineModal" class="btn gray">Cancel</button>
            </div>
        </div>
    </div>
</div>
<kb-media-dialog params="data: mediaDialogData"></kb-media-dialog>
<div data-bind="component: { name: 'kb-relation-modal' }"></div>
<script>
    Kooboo.styleEditor = {};
</script>
<script>
    (function() {
        Kooboo.loadJS([
            "/_Admin/Scripts/kooboo/Guid.js",
            "/_Admin/Scripts/kobindings.sortable.js",
            "/_Admin/Scripts/components/kbUploadProgressor.js",
            "/_Admin/Scripts/components/kbTable.js",
            "/_Admin/Scripts/components/kbRelationModal.js",
            "/_Admin/Scripts/lib/jquery-ui-customized.js",
            "/_Admin/Scripts/styleEditor/components/kb-style-list.js",
            "/_Admin/Scripts/components/kb-media-dialog.js",
            "/_Admin/Scripts/components/kbBreadcrumb.js",
            "/_Admin/Scripts/kobindings.spectrum.js",
            "/_Admin/Scripts/styleEditor/CSSRule.js",
            "/_Admin/Scripts/kobindings.typeahead.js",
            "/_Admin/Scripts/kooboo/Color.js",
            "/_Admin/Scripts/tableModel.js",
            "/_Admin/Scripts/lib/bootstrap3-typeahead.min.js",
            "/_Admin/Scripts/lib/spectrum/spectrum-custom.js"
        ])
        Kooboo.loadCSS([
            "/_Admin/Scripts/lib/spectrum/spectrum.css"
        ])
    })()
</script>
<script src="/_Admin/View/Development/Styles.js"></script>